unit Helpers.Numerics;

interface

uses
  System.SysUtils;

type
  TInt8Helper = record helper for Int8
  public
    function ToString: string; inline;
    function Format(const pMascara: string): string; inline;
    function Abs: UInt8;
  end;

  TUInt8Helper = record helper for UInt8
  public
    function ToString: string; inline;
    function Format(const pMascara: string): string; inline;
  end;

  TInt16Helper = record helper for Int16
  public
    function ToString: string; inline;
    function Format(const pMascara: string): string; inline;
    function Abs: UInt16;
  end;

  TUInt16Helper = record helper for UInt16
  public
    function ToString: string; inline;
    function Format(const pMascara: string): string; inline;
  end;

  TInt32Helper = record helper for Int32
  public
    function ToString: string; inline;
    function Format(const pMascara: string): string; inline;
    function Abs: UInt32;
  end;

  TUInt32Helper = record helper for UInt32
  public
    function ToString: string; inline;
    function Format(const pMascara: string): string; inline;
  end;

  TInt64Helper = record helper for Int64
  public
    function ToString: string; inline;
    function Format(const pMascara: string): string; inline;
    function Abs: UInt64;
  end;

  TUInt64Helper = record helper for UInt64
  public
    function ToString: string; inline;
    function Format(const pMascara: string): string; inline;
  end;

  TCurrencyHelper = record helper for Currency
  public
    function ToString: string; inline;
    function Trunc: Int64; inline;
    function Round: Int64; inline;
    function RoundTo(const pDigitos: ShortInt): Currency; inline;
    function Format(const pMascara: string): string; inline;
  end;

  TDoubleHelper = record helper for Double
  public
    function ToString: string; inline;
    function Trunc: Int64; inline;
    function Round: Int64; inline;
    function RoundTo(const pDigitos: ShortInt): Currency; inline;
    function Format(const pMascara: string): string; inline;
  end;


implementation

uses
  System.Math;

{ TInt32Helper }

function TInt32Helper.Abs: UInt32;
begin
  Result := System.Abs(Self);
end;

function TInt32Helper.Format(const pMascara: string): string;
begin
  Result := System.SysUtils.FormatFloat(pMascara, Self);
end;

function TInt32Helper.ToString: string;
begin
  Result := System.SysUtils.IntToStr(Self);
end;

{ TInt64Helper }

function TInt64Helper.Abs: UInt64;
begin
  Result := System.Abs(Self);
end;

function TInt64Helper.Format(const pMascara: string): string;
begin
  Result := System.SysUtils.FormatFloat(pMascara, Self);
end;

function TInt64Helper.ToString: string;
begin
  Result := System.SysUtils.IntToStr(Self);
end;

{ TCurrencyHelper }

function TCurrencyHelper.Format(const pMascara: string): string;
begin
  Result := System.SysUtils.FormatCurr(pMascara, Self);
end;

function TCurrencyHelper.Round: Int64;
begin
  Result := System.Round(Self);
end;

function TCurrencyHelper.RoundTo(const pDigitos: ShortInt): Currency;
begin
  Result := System.Math.RoundTo(Self, pDigitos);
end;

function TCurrencyHelper.ToString: string;
begin
  Result := System.SysUtils.CurrToStr(Self);
end;

function TCurrencyHelper.Trunc: Int64;
begin
  Result := System.Trunc(Self);
end;

{ TDoubleHelper }

function TDoubleHelper.Format(const pMascara: string): string;
begin
  Result := System.SysUtils.FormatFloat(pMascara, Self);
end;

function TDoubleHelper.Round: Int64;
begin
  Result := System.Round(Self);
end;

function TDoubleHelper.RoundTo(const pDigitos: ShortInt): Currency;
begin
  Result := System.Math.RoundTo(Self, pDigitos);
end;

function TDoubleHelper.ToString: string;
begin
  Result := System.SysUtils.FloatToStr(Self);
end;

function TDoubleHelper.Trunc: Int64;
begin
  Result := System.Trunc(Self);
end;

{ TInt16Helper }

function TInt16Helper.Abs: UInt16;
begin
  Result := System.Abs(Self);
end;

function TInt16Helper.Format(const pMascara: string): string;
begin
  Result := System.SysUtils.FormatCurr(pMascara, Self);
end;

function TInt16Helper.ToString: string;
begin
  Result := System.SysUtils.IntToStr(Self);
end;

{ TUInt16Helper }

function TUInt16Helper.Format(const pMascara: string): string;
begin
  Result := System.SysUtils.FormatCurr(pMascara, Self);
end;

function TUInt16Helper.ToString: string;
begin
  Result := System.SysUtils.IntToStr(Self);
end;

{ TUInt32Helper }

function TUInt32Helper.Format(const pMascara: string): string;
begin
  Result := System.SysUtils.FormatFloat(pMascara, Self);
end;

function TUInt32Helper.ToString: string;
begin
  Result := System.SysUtils.IntToStr(Self);
end;

{ TInt8Helper }

function TInt8Helper.Abs: UInt8;
begin
  Result := System.Abs(Self);
end;

function TInt8Helper.Format(const pMascara: string): string;
begin
  Result := System.SysUtils.FormatCurr(pMascara,  Self);
end;

function TInt8Helper.ToString: string;
begin
  Result := System.SysUtils.IntToStr(Self);
end;

{ TUInt8Helper }

function TUInt8Helper.Format(const pMascara: string): string;
begin
  Result := System.SysUtils.FormatCurr(pMascara, Self);
end;

function TUInt8Helper.ToString: string;
begin
  Result := System.SysUtils.IntToStr(Self);
end;

{ TUInt64Helper }

function TUInt64Helper.Format(const pMascara: string): string;
begin
  Result := System.SysUtils.FormatFloat(pMascara, Self);
end;

function TUInt64Helper.ToString: string;
begin
  Result := System.SysUtils.IntToStr(Self);
end;

end.
